#!/bin/sh

DIR_BIN=`dirname $0`
. ${DIR_BIN}/set-client-env.sh

cp -f ${DIR_BIN}/../classloader/patch/*.jar  ${DIR_BIN}/../classloader

DEBUG_OPTIONS=
if [ "$1" = "debug" ]
then
   DEBUG_OPTIONS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000"
fi

if [ "${JVM_INITIAL_HEAPSIZE}" = "" ] 
then
  JVM_INITIAL_HEAPSIZE=64
fi

if [ "${JVM_MAX_HEAPSIZE}" = "" ]
then
   JVM_MAX_HEAPSIZE=256
fi

if [ "${JVM_MAX_PERMSIZE}" = "" ] 
then
   JVM_MAX_PERMSIZE=128
fi

if [ "${ENABLE_CDN}" = "" ]
then 
   ENABLE_CDN=false
fi

CLASSLOADER="com.kingdee.eas.client.startup.classloader.SmartClassLoader"
MAIN_CLASS="com.kingdee.eas.tools.bodyguard.BodyguardDlg"

JAVA_VENDOR="SUN"
if [ -f ${JAVA_HOME}/jre/lib/server.jar ]
then
   JAVA_VENDOR="IBM"
fi
if [ -f ${JAVA_HOME}/console/ManagementConsole.jar ]
then
   JAVA_VENDOR="BEA"
fi

if [ ${JAVA_VENDOR} = "SUN" ]
then
  JVM_CUSTOM_PARMS="${JVM_CUSTOM_PARMS} -XX:+HeapDumpOnOutOfMemoryError"
fi

JAVALIB="${JAVA_HOME}/jre/lib/plugin.jar:${JAVA_HOME}/lib/plugin.jar"

THIRDLIB="${EAS_HOME}/client/classloader/log4j-1.2.6.jar:${EAS_HOME}/client/classloader/slf4j-api-1.6.1.jar:${EAS_HOME}/client/classloader/foxtrot.jar:${EAS_HOME}/client/classloader/ant.jar:${EAS_HOME}/client/classloader/ant-launcher.jar"

EASLIB="${EAS_HOME}/client/classloader/kdupdater.jar:${EAS_HOME}/client/classloader/apploader.jar:${EAS_HOME}/client/classloader/consultant.jar"

CLASSPATH="${JAVALIB}:${THIRDLIB}:${EASLIB}"
export CLASSPATH

CMD="${JAVA_HOME}/bin/java -javaagent:/Users/raoli/Documents/myassigent2_jar/myassigent2.jar -Xmx${JVM_MAX_HEAPSIZE}m -Xms${JVM_INITIAL_HEAPSIZE}m -XX:MaxPermSize=${JVM_MAX_PERMSIZE}m ${JVM_CUSTOM_PARMS} ${DEBUG_OPTIONS} -DENABLE_CDN=${ENABLE_CDN} -Dsun.java2d.d3d=false -Dsun.net.client.defaultConnectTimeout=30000 -DSESSIONNAME=${SESSIONNAME}  -Dsun.net.client.defaultReadTimeout=30000 -Dsun.awt.font.advancecache=off -Djava.library.path=${EAS_HOME}/client/deploy/client -Dlog4j.configuration=file:${EAS_HOME}/client/deploy/client/log4j.properties -DEAS_HOME=${EAS_HOME} -Djava.system.class.loader=${CLASSLOADER} -classpath ${CLASSPATH} ${MAIN_CLASS} ${EAS_HOME} ${UPDATE_SERVER} ${EAS_SERVER} ${ONDEMAND_UPDATE} 1>/dev/null 2>&1 &"

export CMD
echo $CMD

$CMD

#END
